package com.hkyp.ss.coursewebadmin.controller;

import com.hkyp.ss.course.apis.AdminUserService;
import com.hkyp.ss.course.apis.CourseBackService;
import com.hkyp.ss.course.apis.NavigationItemService;
import com.hkyp.ss.course.apis.dto.common.PageReq;
import com.hkyp.ss.course.apis.dto.common.PageResp;
import com.hkyp.ss.course.apis.dto.request.AdminLoginRequestDTO;
import com.hkyp.ss.course.apis.dto.request.CourseDTO;
import com.hkyp.ss.course.apis.dto.request.HomePageCourseDTO;
import com.hkyp.ss.course.apis.dto.response.CourseBackVO;
import com.hkyp.ss.course.apis.dto.response.FirstCommentVO;
import com.hkyp.ss.course.apis.exception.UnacceptableException;
import com.hkyp.ss.course.apis.utils.BeanMapper;
import com.hkyp.ss.coursewebadmin.dto.base.ResultBean;
import com.hkyp.ss.coursewebadmin.dto.request.BatchActionCourseDTO;
import com.hkyp.ss.coursewebadmin.dto.request.WebAdminLoginRequestDTO;
import com.hkyp.ss.coursewebadmin.dto.request.WebCourseDTO;
import com.hkyp.ss.coursewebadmin.dto.request.WebHomePageCourseDTO;
import com.hkyp.ss.coursewebadmin.utils.OSSUtil;
import com.hkyp.ss.coursewebadmin.utils.UserSessionUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

@Api(description = "课程后台管理-登录")
@Slf4j
@RestController
@RequestMapping(value = "/a/")
public class BackLoginController {


    @Reference(version = "1.0")
    private AdminUserService adminUserService;

    /**
     * 登录  密码是'后台管理'全拼小写加123 ->> houtaiguanli123
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "课程详情  ")
    @RequestMapping(value = "/back/login", method = RequestMethod.POST)
    public ResultBean login( @Valid @RequestBody WebAdminLoginRequestDTO webAdminLoginRequestDTO){

        AdminLoginRequestDTO requestDTO = BeanMapper.map(webAdminLoginRequestDTO, AdminLoginRequestDTO.class);
        String token = adminUserService.login(requestDTO);
        Map<String,String> map = new HashMap<>();
        map.put("token",token);
        return new ResultBean<>(map);
    }

}
